<?php 


class PlaceInformation extends Eloquent{


	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'place_informations';
	protected $primaryKey = 'id';
	public $timestamps = false;

	public function place(){
		$place = $this->belongsTo('Place','id');
		return $place != null ? $place : null;
	}

	public function placeProduct(){
		$availableAt = $this->belongsToMany('PlaceProduct','place_information_has_place_product','place_information_id','place_product_id');
		return $availableAt;
	}

	public function mainService(){
		$availableProducts = $this->hasMany('PlaceHasProduct','place_information_id')->where('main_service','=',1);
		return $availableProducts;
	}

	public function addressOf(){
		$addressOf = $this->belongsTo('Address','address_id');
		return $addressOf != null ? $addressOf :null;
	}
}
